<?php
    if($detail_blog->num_rows()>0)
    {
        $aRow=$detail_blog->row();
    }
?>
<?php echo form_open_multipart('blog/detail_blog/'.$aRow->id);?>
<div id="wrapper-content" >
  <div class="titre_home" >Détail du blog</div>
<table width="90%">
    <tr>
        <td><a><?php echo $aRow->name?></a></td>
    </tr>
    <tr>
        <?php
            $datestring = "%d/%m/%Y - %h:%i %a"; 
            $time=$aRow->blog_date;
            $mdate = mdate($datestring, $time); 
        ?>
        <td colspan="2"><?php echo $mdate; ?></td>
    </tr>
    <tr>
        <?php
            $image_path = './assets/img_blog/thumbs/' . $aRow->image;
            if (file_exists($image_path) && $aRow->image!=null) {
                $image_path = base_url() . 'assets/img_blog/thumbs/' . $aRow->image;

            } else {
                $image_path =root_url('seatting-falin'). 'assets/noimage.gif';
            }
        ?>     
        <td valign="center"><img src="<?php echo $image_path ;?>" height="150px"  alt=""></td>
        <td  style="padding-left: 10px;"><?php echo $aRow->description ?></td>
    </tr>               
</table>
<?php echo form_close() ?>
<?php if($this->session->userdata('user_id')==TRUE){?>
    <?php echo form_open_multipart('blog/add_comment/'.$aRow->id)?>
    <table width="90%">
        <tr>
            <td><label for="intro">Ajouter un commentaire</label> <label style="color: #B7B7B7;" for="commentaires">(<?php echo $total;?> commentaires)</label></td>
        </tr>
        <tr>
            <td>
                <textarea cols="60" rows="8" id="comment" name="comment"><?php echo set_value('comment'); ?></textarea>
                <?php echo form_error('comment')?>
            </td>
        </tr>
        <tr><td align="right"><input type="submit" value=" Enregistrer " name="submit" id="submit"></td></tr>
    </table>
    <?php echo form_close(); ?>
<?php }?>
 <table align="center" width="100%" class="list" >
        <thead>
            <tr>
                <th colspan="3"></th>
            </tr>
        </thead>

        <?php  foreach($comments as $comment):?>
            <?php     
                $image = './../assets/avatar/images/' . $comment['gravatar'];
                if (file_exists($image) && $comment['gravatar'] != null) {
                    $image = root_url('seatting-falin') . 'assets/avatar/images/' . $comment['gravatar'];
                } else {
                    $image = root_url('seatting-falin') . 'assets/noimage.gif';
                }

                $date=$comment['comment_date'];
                $post_date=timespan($date,now());
            ?>  
            <tr class="highlight">
                <td width="10%" valign="top" colspan="2">
                    <p><img border="0" src="<?php echo $image; ?>" width="60" alt=""/></p>
                </td>
                <td>
                    <p><?php echo $comment['content']; ?></p>
                    <p style="font-size: small;color: orangered"><?php echo $comment['display_name']; ?> <span style="color: blue"><?php echo $post_date; ?></span></p>
                </td>
            </tr>
            <?php endforeach; ?>
    </table>
    <?php echo $pagination; ?>
</div>

